<?php

class bannerAdminPlugin extends commonMod
{
    public function __construct()
    {
        parent::__construct();
        $config['TPL_TEMPLATE_PATH'] = dirname(__file__) . '/template/';
        $this->tpl = new cpTemplate($config);
    }

    //---------------------------------------全局信息结束----------------------------------------------------//

    //本插件后台首页
    public function index()
    {
        //以下为插件类方法
		$list=$this->model->table('extend_banner')->order('id desc')->select();
		$this->assign('list',$list);
		$this->display('admin_index');
    }

    //添加
    public function add()
    {
		$this->model->table('extend_banner')->where('pid=0')->delete(); //删除现有图
		$url=$_POST['url'];
        $name=$_POST['name'];
        $aurl=$_POST['aurl'];
        for ($i = 0; $i < count($url); $i++) {
            $data['url'] = $url[$i];
            $data['name'] = $name[$i];
            $data['aurl'] = $aurl[$i];
            $this->model->table('extend_banner')->data($data)->insert();
        }      
		$this->success('幻灯片添加成功！');  
    }
	
	//设置
    public function adminsetting()
    {
            $this->assign('info',$this->plus_configout());
            $this->display('admin_setting');
    }
    
    //设置
    public function setting_post()
    {
        //修改配置
        $data['width']=$_POST['width'];
        $data['height']=$_POST['height'];
        $this->plus_configin($data);//修改配置
        $this->success('幻灯片设置成功！');
    }

}

?>